<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:useBean id="connection" class = "com.wy.JDBConnection" scope="page"></jsp:useBean>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<%ResultSet rs =null;
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String password = request.getParameter("password");
if(name == "" && name == null && password == "" && password ==null){
%>
<jsp:forward page="index.jsp"/>
<%}else {
	String sql = "select * from tb_customer where name = '"+ name+"'  and password = '" +password+"'";
	rs = connection.executeQuery(sql);
	if(rs.next()){
		session.setAttribute("name", rs.getString("name"));
		session.setAttribute("pow", rs.getString("pow"));
		session.setAttribute("login", "success");
		System.out.println("name :" + rs.getString("name") +"; pow : " +rs.getString("pow"));
	
 %>
<script language= "javascript">
alert("登录成功!!");
window.location.href="index.jsp";
</script>
<%}else{
	%>
	<script language= "javascript">
	alert("登录失败!!");
	history.back();
	</script>
<%}} %> 
<body>

</body>
</html>